package cn.javass.dp.command.example4;

public class Client {
    public static void main(String[] args) {
        OperationApi operation = new Operation();
        Calculator cal = new Calculator();

        Command command  = new AddCommand(operation,5);
        Command command1 = new SubstractCommand(operation,2);


        //+5  =5
        cal.setAddCmd(command);
        cal.addPressed();
        System.out.println(operation.getResult());

        //-2   =3
        cal.setSubstractCmd(command1);
        cal.substractPressed();
        System.out.println(operation.getResult());

        //撤销  5
        cal.undoPressed();
        System.out.println(operation.getResult());

        //恢复操作
        cal.undoPressed();
        System.out.println(operation.getResult());

        //恢复操作
        cal.undoPressed();
        System.out.println(operation.getResult());
    }
}
